import React, { Suspense } from "react";
import { BrowserRouter, Route, Routes, Navigate } from
  "react-router-dom";
import Router from "./router/routerconfig";
import { RouterItem } from "./utils/type";
// import TokenRefresh from "./request/useTokenRefresh";
function App() {
  const renderRouters = (arr: RouterItem[]) => {
    // TokenRefresh()
    return (
      arr && arr.map((item, index) => {
        return (
          <Route
            key={index}
            path={item.path}
            element={
              item.element ? (
                <item.element></item.element>
              ) : (
                <Navigate to={item.to}></Navigate>
              )
            }
          >
            {item.children && renderRouters(item.children)}
          </Route>
        );
      })
    );
  };

  return (
    <div>
      {/* <p>{import.meta.env.VITE_TITLE}</p> 111*/}
      <Suspense fallback={<div>loading.....</div>}>
        <BrowserRouter
        basename="poster62"
        >
          <Routes>{renderRouters(Router)}</Routes>
        </BrowserRouter>
      </Suspense>
    </div>

  );
}

export default App;
